package com.fjd.mapper;

import com.fjd.vo.Category12VO;
import com.fjd.vo.Category4VO;
import com.fjd.vo.CategoryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper
public interface ProductCategoryMapper {

    @Select("select parent_id from product_category where product_id = #{id}")
    String getParentNameById(String productId);

    @Select("select product_id,product_name from product_category where type = '一级目录' ")
    List<CategoryVO> getInfo();

    @Select("select product_id,product_name,parent_id from product_category where type IN ('一级目录', '二级目录') ")
    List<Category12VO> getInfo12();

    @Select("select * from product_category where type = '三级目录' ")
    List<Category4VO> getInfo3();

    @Select("select * from product_category where parent_id = #{id}")
    List<Category4VO> getInfoByParentId(String parentId);

    @Update("update product_category set price = #{price} where product_id = #{specId}")
    boolean updatePrice(String specId, Integer price);

    @Select("select product_name from product_category where product_id = #{categoryId}")
    String getCategoryNameByCategoryId(String categoryId);

}
